/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.catosist.run.dataaccess.domain.hibernate;

import com.catosist.run.dataaccess.base.hibernate.HibernateGenericDAO;
import com.catosist.run.dataaccess.domain.GuiaDao;
import com.catosist.run.dataaccess.model.GuiaVO;
import java.io.Serializable;
import java.util.List;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

/**
 *
 * @author igorov
 */
public class HibernateGuiaDao extends HibernateGenericDAO<GuiaVO, Integer> implements GuiaDao{
    public HibernateGuiaDao() {
        super(GuiaVO.class);
    }

    public List<GuiaVO> getByComprobanteId(int comprobanteId) {
        DetachedCriteria detachedCriteria = DetachedCriteria.forClass(GuiaVO.class);
        detachedCriteria.add(Restrictions.eq("comprobante.id", comprobanteId));
        List<GuiaVO> guiaVOs = listByCriteria(detachedCriteria);
//        System.out.println("Cantidad dao: "+guiaVOs.size()+comprobanteId);
        return guiaVOs;
    }
    
    public List<GuiaVO> getByNumero(String numero) {
        return this.getSession().
                createSQLQuery("SELECT * FROM guia where numero = " + numero +";").
                addEntity(GuiaVO.class).list();
    }

}
